package com.rainman.simpleredis.demo.scheduled_worker;

import com.rainman.simpleredis.core.scheduled.ScheduledInfo;
import com.rainman.simpleredis.core.scheduled.SimpleScheduledWorkerInterface;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * 测试固定定时器
 *
 */
@Component
public class TestSch implements SimpleScheduledWorkerInterface {

    private ScheduledInfo scheduledInfo=ScheduledInfo.buildRate(30000L);
    @Override
    public void doWork() {
        System.out.println("我是30s一次的定时任务,执行时间为1s"+new Date());

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {


        }

    }

    @Override
    public String key() {
        return "TEST";
    }

    @Override
    public ScheduledInfo info() {

        return scheduledInfo;
    }
}
